package org.jeecg.modules.cosmetic.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cosmetic.handler.IngredientReviewHandler;
import org.jeecg.modules.cosmetic.model.vo.IngredientProductVO;
import org.jeecg.modules.cosmetic.model.vo.IngredientReviewVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


/**
 * <p>
 * 成份审核表 前端控制器
 * </p>
 *
 * @author liqing
 * @since 2023-03-29
 */
@Api(tags = "成分审核")
@RestController
@RequestMapping("/api/review")
public class TIngredientReviewController {

    @Resource
    private IngredientReviewHandler ingredientReviewHandler;

    @ApiOperation(value = "成分审核-产品配方-查询", notes = "成分审核-产品配方-查询")
    @PostMapping(value = "/query_by_product_id")
    public Result<?> queryFormulaList(@RequestBody IngredientProductVO vo) throws Exception{
        return ingredientReviewHandler.queryFormulaReviewList(vo.getProductId());
    }

    @ApiOperation(value = "成分审核-产品配方-导入", notes = "成分审核-产品配方-导入")
    @PostMapping(value = "/import")
    public Result<?> importExcel(HttpServletRequest request) throws Exception {
        return ingredientReviewHandler.importFormulaExcel((MultipartHttpServletRequest) request);
    }

    @ApiOperation(value = "成分审核-提交审核", notes = "成分审核-提交审核")
    @PostMapping(value = "/submit")
    public Result<?> submitReview(@RequestBody IngredientReviewVO vo) {
        return ingredientReviewHandler.submitReview(vo.getMessage(), vo.getProductId());
    }
}
